﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Close.io.API;
using Newtonsoft.Json;

namespace Close.io.Workbench
{
	class Program
	{
		static void Main(string[] args)
		{


			var closeio = new CloseIo();

			var lead = new Lead("Test Company6", "Test Company6", "Potential", "www.test.com", "This is the description");
			var address = new Lead.Address()
			{
				Address1 = "10540 NW 56th Drive",
				City = "Coral Springs",
				State = "Fl",
				Country = "USA",
				ZipCode = "33076",
				Label = "Business"
			};

			lead.Addresses = new List<Lead.Address>() {address};

			lead = closeio.AddLead(lead);

			var id = lead.Id;


			var contact = new Contact
			{
				Name = "John Smith",
				LeadId = id

			};

			

			closeio.AddContact(contact);

			lead.Url = "www.test6.com";

			lead = closeio.UpdateLead(lead);


			var update = CloseIoUpdate<Lead>.Add(p => p.UpdatedBy, "www.test7.com");

			closeio.UpdateLead(lead.Id, update);


			//var c = count;
		}

		private static void GetValue()
		{
			var file = File.ReadAllText("..\\..\\test1.json");

			var obj = JsonConvert.DeserializeObject<Lead>(file);

			var txt = JsonConvert.SerializeObject(obj);

			File.WriteAllText("..\\..\\test1a.json", txt, Encoding.UTF8);

			var t = 1;
		}
	}
}
